import axios from './request'
// console.log(typeof axios);// 'function'
// 服务器地址
export const host = 'http://localhost:3001'

// 处理图片的接口
export const uploadPhoto = (data={})=>{
    return axios.post(`${host}/api/photo/upload`,data,{headers:{ 'Content-Type': 'multipart/form-data'}})
}
export const removePhoto = (data={})=>{
    return axios.post(`${host}/api/photo/delete`,data)
}

// 处理轮播图的接口
export const publishBanner = (data={})=>{
    return axios.get(`${host}/api/banner/add`,{params: data})
}
export const listBanner = ()=>{
    return axios.get(`${host}/api/banner/list`)
}

export const searchBanner = (data={})=>{
    return axios.get(`${host}/api/banner/search`,{params: data})
}
export const removeBanner = (data={})=>{
    return axios.get(`${host}/api/banner/remove`,{params: data})
}
export const modifyBanner = (data={})=>{
    return axios.get(`${host}/api/banner/modify`,{params: data})
}

// 处理导航的接口
export const addCate = (data={})=>{
    return axios.get(`${host}/api/cate/add`,{params: data})
}
export const listCate = (data={})=>{
    return axios.get(`${host}/api/cate/list`,{params: data})
}
export const searchCate = (data={})=>{
    return axios.get(`${host}/api/cate/search`,{params: data})
}
export const removeCate = (data={})=>{
    return axios.get(`${host}/api/cate/remove`,{params: data})
}
export const modifyCate = (data={})=>{
    return axios.get(`${host}/api/cate/modify`,{params: data})
}
export const itemsCate = (data={})=>{
    return axios.get(`${host}/api/cate/items`,{params: data})
}


// 用户相关的接口（管理员）
// 判断用户是否登录
export const isLogined = (data={})=>{
    console.log(data)
    return axios.post(`${host}/api/user/isLogined`,data)
}
export const adminLogin = (data={})=>{
    return axios.post(`${host}/api/admin/login`,data)
}

// 文章接口处理
export const publishArticle = (data={})=>{
    return axios.post(`${host}/api/article/publish`,data, {headers: {token: localStorage.getItem("AUTO_TOKEN")}})
}

export const itemsArticle = (data={})=>{
    return axios.post(`${host}/api/article/items`,data)
}

export const deleteArticle = (data={})=>{
    return axios.post(`${host}/api/article/delete`,data, {headers: {token: localStorage.getItem("AUTO_TOKEN")}})
}

// 用户接口
export const itemsUser = (data={})=>{
    return axios.post(`${host}/api/user/items`,data)
}
export const deleteUser = (data={})=>{
    return axios.post(`${host}/api/user/delete`,data, {headers: {token: localStorage.getItem("AUTO_TOKEN")}})
}